#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# @Project:     effective_life_pc
# @File:        u_decorators.py
# @Author:      Fan GuiChuan
# @Date:        2024/11/15 8:29
# @Version:     Python3.7
# @Description:
from .u_log import BaseLogManager


def cache_exception(default_value, logger: BaseLogManager):
    def decorator(func):
        def wrapper(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except Exception as e:
                logger.exception(e)
                return default_value

        return wrapper
    return decorator
